package gui.utils;

import core.utils.Variable;
import gui.actions.CheckboxAction;

import javax.swing.*;

/**
 * An extension of the <code>JCheckBox</code> class which associates it with a 
 * <code>Variable</code> object.
 */
public class CheckBoxWithVariable extends JCheckBox {
	private static final long serialVersionUID = 1L;
	
	private final Variable var;

	public CheckBoxWithVariable(Variable var, CheckboxAction action) {
		super(action);
		this.setText(var.getName() + " [" + var.getUnit() + "]");
		this.var = var;
	}
	
	/**
	 * Returns the <code>Variable</code> associated with this checkbox.
	 * @return The <code>Variable</code> associated with this checkbox.
	 */
	public Variable getVariable() {
		return var;
	}
}
